﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SoftwareEngineering_Project
{
    public partial class Logs
    {
        private SoftwareEngineering_Project.User CurrentUser
        {
            get
            {
                return (SoftwareEngineering_Project.User)Session["CurrentUser"];
            }
            set
            {
                Session["CurrentUser"] = value;
            }
        }

        public Logs()
        {
            ;
        }

        public void CreateLog(String TypeID, String message)
        {
            string query = "INSERT INTO Sys_Transaction (TypeID, Username, TransactionDate) VALUES (" + TypeID + "," + CurrentUser.EmployeeID + ",'" + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss") + "')";
            DBConnection DB = new DBConnection();
            try
            {

                ////DB.cnTransact.Open();
                DB.ExecuteCommandNonquery(query);
                ////DB.cnTransact.Close();
            }
            catch(Exception err)
            {
                err.Message.ToString();
            }
        }

        public void CreateLog(DBConnection connection, String TypeID, String message)
        {
            string query = "INSERT INTO Sys_Transaction (TypeID, Username, TransactionDate) VALUES (" + TypeID + "," + CurrentUser.EmployeeID + ",'" + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss") + "')";
            try
            {
                connection.ExecuteCommandNonquery(query);
            }
            catch (Exception err)
            {
                err.Message.ToString();
            }
        }
    }
}